<!DOCTYPE html>
<html lang="zh">
<head>
    <th:block th:include="include :: header('服务报告')" />
    <th:block th:include="include :: summernote-css" />
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
<!--                    <h5>编辑/保存为html</h5>-->
                    <button id="edit" class="btn btn-primary btn-xs m-l-sm" onclick="edit()" type="button">编辑</button>
                    <button id="save" class="btn btn-primary  btn-xs m-l-sm" onclick="save()" type="button">保存</button>
                    <button id="print" class="btn btn-primary  btn-xs m-l-sm" onclick="printpage()" type="button">打印</button>
                </div>
                <div class="ibox-content" id="eg">
                    <div class="click2edit wrapper printContent">

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: summernote-js" />
<script>
    $(document).ready(function () {
        $('.click2edit').summernote({
            lang: 'zh-CN',
            height: 800
        });
    });
    var edit = function () {
        $("#eg").addClass("no-padding");
        $('.click2edit').summernote({
            lang: 'zh-CN',
            focus: true
        });
    };
    function printpage() {
        let newstr = $('.click2edit').summernote('code');
        // let oldstr = document.body.innerHTML;
        document.body.innerHTML = newstr;
        window.print();
        // document.body.innerHTML = oldstr;
        location.reload();
        console.log("--------------------------------------");
        console.log(newstr);
        $('.click2edit').summernote('code', newstr);

    }
    var save = function () {
        $("#eg").removeClass("no-padding");
        var aHTML = $('.click2edit').summernote('code');

        $('.click2edit').summernote('destroy');
    };
</script>
</body>
</html>
